﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Vehicles
{

    public interface IPassengerCarrier
    {
        int GetPassenger();
    }

    public interface IHeavyLoadCarrier
    {
        float GetHeavyLoad();
    }

    public abstract class Vehicle
    {

    }

    public abstract class Car : Vehicle
    {
  
    }

    public abstract class Train : Vehicle
    {

    }

    public class Compact : Car, IPassengerCarrier
    {
        public int GetPassenger()
        {
            return 4;
        }

        public override string ToString()
        {
            return base.ToString() + " 小汽车 载客数：" + GetPassenger();
        }
    }

    public class SUV : Car, IPassengerCarrier
    {
        public int GetPassenger()
        {
            return 7;
        }

        public override string ToString()
        {
            return base.ToString() + " SUV 载客数：" + GetPassenger();
        }
    }

    public class Pickup : Car, IPassengerCarrier, IHeavyLoadCarrier
    {
        public float GetHeavyLoad()
        {
            return 5000;
        }

        public int GetPassenger()
        {
            return 2;
        }

        public override string ToString()
        {
            return base.ToString() + " 货车 载客数：" + GetPassenger() + " 载货：" + GetHeavyLoad() + "KG";
        }
    }

    public class PassengerTrain : Train, IPassengerCarrier
    {
        public int GetPassenger()
        {
            return 1700;
        }

        public override string ToString()
        {
            return base.ToString() + " 货运火车 载客数：" + GetPassenger();
        }
    }

    public class FreightTrain : Train, IHeavyLoadCarrier
    {
        public float GetHeavyLoad()
        {
            return 1000000;
        }

        public override string ToString()
        {
            return base.ToString() + " 货运火车 载货：" + GetHeavyLoad() + "KG";
        }
    }

    public class _424DoubleBogey : Train, IPassengerCarrier, IHeavyLoadCarrier
    {
        public float GetHeavyLoad()
        {
            return 800;
        }

        public int GetPassenger()
        {
            return 1000;
        }

        public override string ToString()
        {
            return base.ToString() + " 424火车 载客数：" + GetPassenger() + " 载货：" + GetHeavyLoad() + "KG";
        }
    }
}

namespace TestVehicles
{

    public interface IPassengerCarrier
    {

    }

    public interface IHeavyLoadCarrier
    {

    }

    public abstract class Vehicle
    {
        
    }

    public abstract class Car : Vehicle
    {

    }

    public abstract class Train : Vehicle
    {

    }

    public class Compact : Car, IPassengerCarrier
    {

    }

    public class SUV : Car, IHeavyLoadCarrier
    {

    }

    public class Pickup : Car, IPassengerCarrier
    {

    }

    public class PassengerTrain : Train, IPassengerCarrier
    {

    }

    public class FreightTrain : Train, IHeavyLoadCarrier
    {

    }

    public class _424DoubleBogey : Train , IPassengerCarrier, IHeavyLoadCarrier
    {

    }
}


namespace Vehicle
{
    public enum E_VehicleType
    {

    }

    public interface IPassengerCarrier
    {
        int GetPassenger();
    }

    public interface IHeavyLoadCarrier
    {
        float GetHeavyLoad();
    }
    public abstract class Vehicle
    {
        public Vehicle()
        {
            Console.WriteLine("Vehicle");
        }
        protected E_VehicleType VehicleType;

        public E_VehicleType GetVehicleType()
        {
            return VehicleType;
        }
    }

    public abstract class Car : Vehicle
    {

    }

    public abstract class Train : Vehicle
    {
        public Train()
        {
            Console.WriteLine("Train");
        }

        public Train(int i)
        {
            Console.WriteLine("Train int i ");
        }
        protected int BoxCount;
    }

    public class Compact : Car, IPassengerCarrier
    {
        public int GetPassenger()
        {
            return 4;
        }

        public override string ToString()
        {
            return base.ToString() + " 小汽车 载客：" + GetPassenger();
        }
    }

    public class SUV : Car, IPassengerCarrier
    {
        public int GetPassenger()
        {
            return 7;
        }

        public override string ToString()
        {
            return base.ToString() + " SUV 载客：" + GetPassenger();
        }
    }

    public class Pickup : Car, IPassengerCarrier, IHeavyLoadCarrier
    {
        public float GetHeavyLoad()
        {
            return 5000;
        }

        public int GetPassenger()
        {
            return 2;
        }

        public override string ToString()
        {
            return base.ToString() + " 货车 载客：" + GetPassenger() + " 载货：" + GetHeavyLoad() + "KG";
        }
    }

    public class PassengerTrain : Train, IPassengerCarrier
    {
        private int PerBoxCount;
        public int GetPassenger()
        {
            return BoxCount * PerBoxCount;
        }

        public override string ToString()
        {
            return base.ToString() + " 客运火车 载客：" + GetPassenger();
        }
    }

    public class FreightTrain : Train, IHeavyLoadCarrier
    {
        
        private float PerBoxHeavy;
        public float GetHeavyLoad()
        {
            return BoxCount * PerBoxHeavy;
        }

        public override string ToString()
        {
            return base.ToString() + "  货运火车  载货：" + GetHeavyLoad() + "KG";
        }
    }

    public class _424DoubleDogey : Train, IPassengerCarrier, IHeavyLoadCarrier
    {
        public _424DoubleDogey() : this(11)
        {
            this.PassengerBoxCount = 1;
            Console.WriteLine("_424DoubleDogey");
            
        }

        public _424DoubleDogey(int i) : base(i)
        {
            Console.WriteLine("_424DoubleDogey int i");
        }

        private int HeavyLoadBoxCount;
        private int PassengerBoxCount;
        private float PerBoxHeavy;
        private int PerBoxCount;
        public float GetHeavyLoad()
        {
            return PerBoxHeavy * HeavyLoadBoxCount;
        }

        public int GetPassenger()
        {
            return PerBoxCount * PassengerBoxCount;
        }

        public override string ToString()
        {
            return base.ToString() + " 424火车 载客：" + GetPassenger() + " 载货：" + GetHeavyLoad() + "KG";
        }
    }

    public class VehicleDataBase
    {
        private ArrayList VehicleArray = new ArrayList();

        public void AddVehicle(Vehicle v)
        {
            SUV suv = new SUV();
            suv.GetPassenger();
            PassengerTrain pt = new PassengerTrain();
            pt.GetPassenger();

            //接口的多态
            IPassengerCarrier passenger;
            passenger = new SUV();
            passenger.GetPassenger();
            passenger = new PassengerTrain();
            passenger.GetPassenger();
            Console.WriteLine(v.ToString());
        }   

        public void AddPassenger(IPassengerCarrier pc)
        {
            Console.WriteLine(pc.GetPassenger());
            Console.WriteLine(pc.ToString());
        }

        public void AddHeavyLoad(IHeavyLoadCarrier pc)
        {
            Console.WriteLine(pc.GetHeavyLoad());
            Console.WriteLine(pc.ToString());
        }
    }
}